<template>
  <UserLayout :active-index="activeIndex" :active-menu="activeMenu">
    <div class="contract-content">
      <h1 class="page-title">签约管理</h1>
          <div class="contract-header">
            <h2>签约管理</h2>
            <p>管理您的租赁合同申请和签署</p>
          </div>

          <div class="contract-content">
            <!-- 租客发起的签约申请 -->
            <el-card class="contract-card">
              <template #header>
                <div class="card-header">
                  <span>我发起的签约申请</span>
                </div>
              </template>

              <div class="contract-list">
                <el-table :data="tenantContracts" style="width: 100%">
                  <el-table-column prop="houseTitle" label="房源信息" width="200"></el-table-column>
                  <el-table-column prop="landlordName" label="房东" width="120"></el-table-column>
                  <el-table-column prop="status" label="状态" width="120">
                    <template #default="scope">
                      <el-tag :type="getContractStatusType(scope.row.status)">
                        {{ getContractStatusText(scope.row.status) }}
                      </el-tag>
                    </template>
                  </el-table-column>
                  <el-table-column prop="applyTime" label="申请时间" width="150"></el-table-column>
                  <el-table-column label="操作" width="200">
                    <template #default="scope">
                      <el-button
                          size="small"
                          @click="viewContractDetail(scope.row)"
                          :disabled="scope.row.status === 'rejected'"
                      >
                        {{ scope.row.status === 'rejected' ? '查看详情' : '查看进度' }}
                      </el-button>
                      <el-button
                          v-if="scope.row.status === 'drafting'"
                          size="small"
                          type="primary"
                          @click="showSignContract(scope.row)"
                      >
                        签署合同
                      </el-button>
                    </template>
                  </el-table-column>
                </el-table>
              </div>
            </el-card>

            <!-- 合同详情 -->
            <el-card class="contract-card" v-if="showContractDetail">
              <template #header>
                <div class="card-header">
                  <span>合同详情</span>
                  <div>
                    <el-button @click="backToList">返回列表</el-button>
                    <el-button
                        v-if="currentContract.status === 'drafting'"
                        type="primary"
                        @click="showSignContract(currentContract)"
                    >
                      签署合同
                    </el-button>
                  </div>
                </div>
              </template>

              <div class="contract-detail">
                <div class="contract-info">
                  <el-row :gutter="20">
                    <el-col :span="12">
                      <div class="info-item">
                        <span class="label">房源信息：</span>
                        <span class="value">{{ currentContract.houseTitle }}</span>
                      </div>
                    </el-col>
                    <el-col :span="12">
                      <div class="info-item">
                        <span class="label">房东：</span>
                        <span class="value">{{ currentContract.landlordName }}</span>
                      </div>
                    </el-col>
                  </el-row>

                  <el-row :gutter="20">
                    <el-col :span="12">
                      <div class="info-item">
                        <span class="label">申请人：</span>
                        <span class="value">{{ currentContract.tenantName }}</span>
                      </div>
                    </el-col>
                    <el-col :span="12">
                      <div class="info-item">
                        <span class="label">申请时间：</span>
                        <span class="value">{{ currentContract.applyTime }}</span>
                      </div>
                    </el-col>
                  </el-row>

                  <el-row :gutter="20">
                    <el-col :span="12">
                      <div class="info-item">
                        <span class="label">租期：</span>
                        <span class="value">{{ currentContract.leaseTerm }}个月</span>
                      </div>
                    </el-col>
                    <el-col :span="12">
                      <div class="info-item">
                        <span class="label">状态：</span>
                        <span class="value">
                          <el-tag :type="getContractStatusType(currentContract.status)">
                            {{ getContractStatusText(currentContract.status) }}
                          </el-tag>
                        </span>
                      </div>
                    </el-col>
                  </el-row>

                  <div v-if="currentContract.rejectReason" class="info-item">
                    <span class="label">拒绝理由：</span>
                    <span class="value reject-reason">{{ currentContract.rejectReason }}</span>
                  </div>
                </div>

                <div class="contract-terms" v-if="currentContract.status !== 'pending' && currentContract.status !== 'rejected'">
                  <h3>合同条款</h3>

                  <div class="term-section">
                    <h4>押金条款</h4>
                    <p>{{ currentContract.depositTerms }}</p>
                  </div>

                  <div class="term-section">
                    <h4>房东义务</h4>
                    <p>{{ currentContract.landlordObligations }}</p>
                  </div>

                  <div class="term-section">
                    <h4>租客义务</h4>
                    <p>{{ currentContract.tenantObligations }}</p>
                  </div>

                  <div class="term-section">
                    <h4>违约责任</h4>
                    <p>{{ currentContract.defaultProvisions }}</p>
                  </div>

                  <div class="term-section">
                    <h4>特殊条款</h4>
                    <p>{{ currentContract.specialClauses }}</p>
                  </div>

                  <div class="term-section">
                    <h4>争议解决</h4>
                    <p>{{ currentContract.disputeResolution }}</p>
                  </div>
                </div>
              </div>
            </el-card>
          </div>
        </div>

      <!-- 签署合同对话框 -->
    <el-dialog
        v-model="showSignContractDialog"
        title="签署合同"
        width="800px"
        :before-close="handleSignDialogClose"
    >
      <div class="contract-preview">
        <h3>房屋租赁合同</h3>

        <div class="contract-section">
          <h4>一、基础信息条款</h4>

          <div class="contract-subsection">
            <h5>合同主体</h5>
            <p><strong>房东：</strong>{{ signingContract.landlordInfo?.name }}，身份证号：{{ signingContract.landlordInfo?.idCard }}，联系方式：{{ signingContract.landlordInfo?.phone }}</p>
            <p><strong>租客：</strong>{{ signingContract.tenantInfo?.name }}，身份证号：{{ signingContract.tenantInfo?.idCard }}，联系方式：{{ signingContract.tenantInfo?.phone }}</p>
          </div>

          <div class="contract-subsection">
            <h5>房屋信息</h5>
            <p><strong>地址：</strong>{{ signingContract.houseInfo?.address }}</p>
            <p><strong>建筑面积：</strong>{{ signingContract.houseInfo?.area }}</p>
            <p><strong>户型：</strong>{{ signingContract.houseInfo?.layout }}</p>
          </div>

          <div class="contract-subsection">
            <h5>租赁用途</h5>
            <p>仅限居住使用，禁止擅自改为群租房或违法用途。</p>
          </div>
        </div>

        <div class="contract-section">
          <h4>二、租赁期限与费用</h4>

          <div class="contract-subsection">
            <h5>租期</h5>
            <p>起止日期：自{{ signingContract.startDate }}至{{ signingContract.endDate }}，租期{{ signingContract.leaseTerm }}个月。</p>
            <p>续约规则：租期满前30日书面协商续约。</p>
          </div>

          <div class="contract-subsection">
            <h5>租金与支付</h5>
            <p><strong>月租金：</strong>人民币{{ signingContract.rent }}元整</p>
            <p><strong>支付方式：</strong>银行转账</p>
            <p><strong>支付时间：</strong>每月5日前付清当月租金</p>
            <p><strong>押金条款：</strong>{{ signingContract.depositTerms }}</p>
          </div>

          <div class="contract-subsection">
            <h5>其他费用</h5>
            <p>水电燃气、物业费、网络费由租客自理。</p>
            <p>维修基金：小额维修由租客承担，大修由房东负责。</p>
          </div>
        </div>

        <div class="contract-section">
          <h4>三、权利义务条款</h4>

          <div class="contract-subsection">
            <h5>房东义务</h5>
            <p>{{ signingContract.landlordObligations }}</p>
          </div>

          <div class="contract-subsection">
            <h5>租客义务</h5>
            <p>{{ signingContract.tenantObligations }}</p>
          </div>
        </div>

        <div class="contract-section">
          <h4>四、违约责任</h4>

          <div class="contract-subsection">
            <h5>租客违约</h5>
            <p>{{ signingContract.tenantDefault }}</p>
          </div>

          <div class="contract-subsection">
            <h5>房东违约</h5>
            <p>{{ signingContract.landlordDefault }}</p>
          </div>
        </div>

        <div class="contract-section">
          <h4>五、特殊条款</h4>

          <div class="contract-subsection">
            <h5>房屋维修</h5>
            <p>{{ signingContract.houseMaintenance }}</p>
          </div>

          <div class="contract-subsection">
            <h5>合同终止</h5>
            <p>{{ signingContract.contractTermination }}</p>
          </div>

          <div class="contract-subsection">
            <h5>争议解决</h5>
            <p>{{ signingContract.disputeResolution }}</p>
          </div>
        </div>

        <div class="contract-section">
          <h4>六、其他必备条款</h4>

          <div class="contract-subsection">
            <h5>物品清单附件</h5>
            <p>详细记录家具、家电品牌及数量（避免退租纠纷）</p>
          </div>

          <div class="contract-subsection">
            <h5>物业交割单</h5>
            <p>水电燃气表底数、钥匙交付记录</p>
          </div>

          <div class="contract-subsection">
            <h5>合同生效条件</h5>
            <p>双方签字+押金/首期租金到账后生效</p>
          </div>
        </div>
      </div>

      <div class="agreement-section">
        <el-checkbox
            v-model="agreeToTerms"
            :disabled="!canCheckAgreement"
            @change="handleAgreementChange"
        >
          我已阅读并同意以上所有合同条款 {{ canCheckAgreement ? '（勾选即表示同意）' : '（' + countdown + '秒后可勾选）' }}
        </el-checkbox>
      </div>

      <template #footer>
        <span class="dialog-footer">
          <el-button
              type="primary"
              @click="confirmSignContract"
              :disabled="!agreeToTerms"
          >
            确认签署
          </el-button>
          <el-button type="danger" @click="showRejectContractDialog">拒绝合同</el-button>
          <el-button @click="cancelSignContract">取消</el-button>
        </span>
      </template>
    </el-dialog>

    <!-- 拒绝合同对话框 -->
    <el-dialog
        v-model="showRejectContractDialogVisible"
        title="拒绝合同"
        width="500px"
        append-to-body
    >
      <el-form>
        <el-form-item label="拒绝理由">
          <el-input
              v-model="rejectReason"
              type="textarea"
              :rows="4"
              placeholder="请输入拒绝理由"
          />
        </el-form-item>
      </el-form>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="cancelRejectContract">取消</el-button>
          <el-button type="primary" @click="confirmRejectContract">确定</el-button>
        </span>
      </template>
    </el-dialog>
  </UserLayout>
</template>

<script setup>
import { ref, onBeforeUnmount } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import UserLayout from '@/components/layout/UserLayout.vue'
import { Document } from '@element-plus/icons-vue'

const router = useRouter()
const activeMenu = ref('contract')
const activeIndex = ref('1')
const showContractDetail = ref(false)
const showSignContractDialog = ref(false)
const showRejectContractDialogVisible = ref(false)
const currentContract = ref({})
const signingContract = ref({})
const agreeToTerms = ref(false)
const canCheckAgreement = ref(false)
const countdown = ref(5)
const rejectReason = ref('')
let countdownInterval = null

// 租客发起的签约申请
const tenantContracts = ref([
  {
    id: 1,
    houseTitle: '精致一居室公寓',
    landlordName: '李四',
    status: 'pending', // pending, approved, rejected, drafting, signed
    applyTime: '2023-06-15 14:30',
    leaseTerm: 12,
    rejectReason: '',
    landlordInfo: {
      name: '李四',
      idCard: '110101199001011234',
      phone: '138****8888'
    },
    tenantInfo: {
      name: '张三',
      idCard: '110101199002021234',
      phone: '139****9999'
    },
    houseInfo: {
      address: '北京市朝阳区CBD建国路123号',
      area: '60㎡',
      layout: '一室一厅'
    },
    startDate: '2023-07-01',
    endDate: '2024-06-30',
    rent: 4500
  },
  {
    id: 2,
    houseTitle: '豪华两居室',
    landlordName: '王五',
    status: 'approved',
    applyTime: '2023-06-10 10:15',
    leaseTerm: 24,
    rejectReason: '',
    landlordInfo: {
      name: '王五',
      idCard: '110101199003031234',
      phone: '137****7777'
    },
    tenantInfo: {
      name: '张三',
      idCard: '110101199002021234',
      phone: '139****9999'
    },
    houseInfo: {
      address: '北京市朝阳区三里屯太古里456号',
      area: '90㎡',
      layout: '两室一厅'
    },
    startDate: '2023-07-15',
    endDate: '2025-07-14',
    rent: 8500
  },
  {
    id: 3,
    houseTitle: '舒适三居室',
    landlordName: '赵六',
    status: 'drafting',
    applyTime: '2023-06-05 09:45',
    leaseTerm: 12,
    rejectReason: '',
    landlordInfo: {
      name: '赵六',
      idCard: '110101199004041234',
      phone: '136****6666'
    },
    tenantInfo: {
      name: '张三',
      idCard: '110101199002021234',
      phone: '139****9999'
    },
    houseInfo: {
      address: '北京市朝阳区国贸SOHO789号',
      area: '120㎡',
      layout: '三室两厅'
    },
    startDate: '2023-07-01',
    endDate: '2024-06-30',
    rent: 12000,
    depositTerms: '押金为两个月租金，退租时房屋设施无损坏且结清水电费后退还',
    landlordObligations: '交房时保证房屋无产权纠纷，设施正常使用，配合办理暂住证等手续',
    tenantObligations: '禁止转租/分租，不得擅自拆改房屋结构，禁止堆放易燃易爆物品',
    tenantDefault: '逾期支付租金：按日加收2%滞纳金，超15日可解除合同；提前退租：扣减押金或支付2个月租金作为违约金',
    landlordDefault: '无故收回房屋：赔偿租客2个月租金+搬家费；未履行维修义务：租客可自行维修并抵扣租金',
    houseMaintenance: '自然损坏由房东负责（如水管老化破裂）；人为损坏由租客承担（如打碎玻璃窗）',
    contractTermination: '租客退租需提前30日书面通知，并结清费用；房东售房需提前60日通知，租客享有优先购买权',
    disputeResolution: '协商不成时，向房屋所在地法院提起诉讼'
  }
])

// 获取合同状态类型
const getContractStatusType = (status) => {
  const statusTypes = {
    'pending': 'warning',
    'approved': 'success',
    'rejected': 'danger',
    'drafting': 'primary',
    'signed': 'success'
  }
  return statusTypes[status] || 'info'
}

// 获取合同状态文本
const getContractStatusText = (status) => {
  const statusTexts = {
    'pending': '待处理',
    'approved': '已同意',
    'rejected': '已拒绝',
    'drafting': '拟定中',
    'signed': '已签署'
  }
  return statusTexts[status] || '未知状态'
}

// 顶部导航栏跳转
const goToHome = () => {
  router.push('/')
}

const goToSearch = () => {
  router.push('/house/search')
}

const goToPublish = () => {
  router.push('/house/publish')
}

const goToMessages = () => {
  router.push('/message')
}

// 用户命令处理
const handleUserCommand = (command) => {
  switch (command) {
    case 'profile':
      router.push('/profile')
      break
    case 'settings':
      router.push('/settings')
      break
    case 'logout':
      ElMessage.success('退出登录成功')
      localStorage.removeItem('userEmail')
      localStorage.removeItem('isLoggedIn')
      router.push('/login')
      break
  }
}

// 侧边栏跳转
const goToPublishNew = () => {
  router.push('/house/publish')
}

const goToMyHouses = () => {
  router.push('/house/my-houses')
}

const goToAgentApply = () => {
  router.push('/agent/apply')
}

const goToAgentStatus = () => {
  router.push('/agent/status')
}

const goToAgentHouses = () => {
  router.push('/agent/houses')
}

const goToTenant = () => {
  router.push('/rental/tenant')
}

const goToLandlord = () => {
  router.push('/rental/landlord')
}

const goToAgentRental = () => {
  router.push('/rental/agent')
}

const goToContract = () => {
  router.push('/contract/tenant')
}

const goToProfile = () => {
  router.push('/profile')
}

// 菜单选择处理
const handleSelect = (key) => {
  switch (key) {
    case '1':
      router.push('/')
      break
    case '2':
      router.push('/house/search')
      break
    case '3':
      router.push('/house/publish')
      break
    case '4':
      router.push('/message')
      break
  }
}

// 查看合同详情
const viewContractDetail = (contract) => {
  showContractDetail.value = true
  currentContract.value = contract
}

// 显示签署合同对话框
const showSignContract = (contract) => {
  signingContract.value = contract
  showSignContractDialog.value = true
  agreeToTerms.value = false
  canCheckAgreement.value = false
  countdown.value = 5

  // 开始倒计时
  countdownInterval = setInterval(() => {
    countdown.value--
    if (countdown.value <= 0) {
      canCheckAgreement.value = true
      clearInterval(countdownInterval)
    }
  }, 1000)
}

// 处理协议勾选变化
const handleAgreementChange = (val) => {
  agreeToTerms.value = val
}

// 取消签署合同
const cancelSignContract = () => {
  showSignContractDialog.value = false
  clearInterval(countdownInterval)
}

// 处理签署对话框关闭
const handleSignDialogClose = (done) => {
  clearInterval(countdownInterval)
  done()
}

// 确认签署合同
const confirmSignContract = () => {
  ElMessageBox.confirm(
      '确定要签署该合同吗？签署后将生成PDF文件并存档。',
      '签署合同',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
  ).then(() => {
    // 模拟签署合同
    setTimeout(() => {
      ElMessage.success('合同签署成功')
      showSignContractDialog.value = false

      // 更新合同状态
      const index = tenantContracts.value.findIndex(item => item.id === signingContract.value.id)
      if (index > -1) {
        tenantContracts.value[index].status = 'signed'
      }

      if (currentContract.value.id === signingContract.value.id) {
        currentContract.value.status = 'signed'
      }

      clearInterval(countdownInterval)
    }, 1000)
  }).catch(() => {
    // 用户取消操作
  })
}

// 显示拒绝合同对话框
const showRejectContractDialog = () => {
  showRejectContractDialogVisible.value = true
  rejectReason.value = ''
}

// 取消拒绝合同
const cancelRejectContract = () => {
  showRejectContractDialogVisible.value = false
}

// 确认拒绝合同
const confirmRejectContract = () => {
  if (!rejectReason.value.trim()) {
    ElMessage.error('请输入拒绝理由')
    return
  }

  ElMessageBox.confirm(
      '确定要拒绝该合同吗？拒绝后将无法再次签署此合同。',
      '拒绝合同',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }
  ).then(() => {
    // 模拟拒绝合同
    setTimeout(() => {
      ElMessage.success('合同已拒绝')
      showRejectContractDialogVisible.value = false
      showSignContractDialog.value = false

      // 更新合同状态
      const index = tenantContracts.value.findIndex(item => item.id === signingContract.value.id)
      if (index > -1) {
        tenantContracts.value[index].status = 'rejected'
        tenantContracts.value[index].rejectReason = rejectReason.value
      }

      if (currentContract.value.id === signingContract.value.id) {
        currentContract.value.status = 'rejected'
        currentContract.value.rejectReason = rejectReason.value
      }

      clearInterval(countdownInterval)
    }, 1000)
  }).catch(() => {
    // 用户取消操作
  })
}

// 返回列表
const backToList = () => {
  showContractDetail.value = false
  currentContract.value = {}
}

// 组件卸载前清理定时器
onBeforeUnmount(() => {
  if (countdownInterval) {
    clearInterval(countdownInterval)
  }
})
</script>

<style scoped>
.contract-container {
  display: flex;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
  background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
}

.background-decoration {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

/* 精美的动态背景 */
.dynamic-background {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(to bottom, #1a2980, #26d0ce);
  overflow: hidden;
}

/* 建筑物 */
.building {
  position: absolute;
  bottom: 0;
  background: rgba(30, 30, 50, 0.8);
  border-radius: 5px 5px 0 0;
  box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.3);
}

.building-1 {
  left: 10%;
  width: 80px;
  height: 300px;
  animation: buildingGlow 4s infinite alternate;
}

.building-2 {
  left: 25%;
  width: 120px;
  height: 400px;
  animation: buildingGlow 5s infinite alternate-reverse;
}

.building-3 {
  left: 45%;
  width: 100px;
  height: 350px;
  animation: buildingGlow 6s infinite alternate;
}

.building-4 {
  left: 65%;
  width: 140px;
  height: 450px;
  animation: buildingGlow 4.5s infinite alternate-reverse;
}

.building-5 {
  left: 80%;
  width: 90px;
  height: 320px;
  animation: buildingGlow 5.5s infinite alternate;
}

@keyframes buildingGlow {
  0% {
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.3);
  }
  100% {
    box-shadow: 0 -5px 25px rgba(100, 200, 255, 0.6);
  }
}

/* 云朵 */
.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  filter: blur(2px);
}

.cloud-1 {
  top: 20%;
  left: 5%;
  width: 80px;
  height: 30px;
  animation: cloudMove 25s linear infinite;
}

.cloud-2 {
  top: 35%;
  left: 70%;
  width: 120px;
  height: 40px;
  animation: cloudMove 30s linear infinite;
}

.cloud-3 {
  top: 15%;
  left: 40%;
  width: 100px;
  height: 35px;
  animation: cloudMove 35s linear infinite;
}

@keyframes cloudMove {
  0% {
    transform: translateX(-100px);
  }
  100% {
    transform: translateX(calc(100vw + 100px));
  }
}

/* 太阳 */
.sun {
  position: absolute;
  top: 80px;
  right: 100px;
  width: 80px;
  height: 80px;
  background: radial-gradient(circle, #ffeb3b, #ffc107);
  border-radius: 50%;
  box-shadow: 0 0 40px #ff9800, 0 0 80px #ff5722;
  animation: sunPulse 3s infinite alternate;
}

@keyframes sunPulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 40px #ff9800, 0 0 80px #ff5722;
  }
  100% {
    transform: scale(1.1);
    box-shadow: 0 0 60px #ff9800, 0 0 100px #ff5722;
  }
}

/* 光线 */
.light-ray {
  position: absolute;
  top: 120px;
  right: 140px;
  width: 400px;
  height: 200px;
  background: linear-gradient(to right, transparent, rgba(255, 235, 59, 0.2), transparent);
  transform-origin: left center;
  animation: rayRotate 10s infinite linear;
}

.ray-1 {
  transform: rotate(0deg);
  animation-delay: 0s;
}

.ray-2 {
  transform: rotate(60deg);
  animation-delay: 2s;
}

.ray-3 {
  transform: rotate(120deg);
  animation-delay: 4s;
}

@keyframes rayRotate {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* 浮动装饰元素 */
.floating-shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  animation: float 15s infinite linear;
}

.shape-1 {
  width: 300px;
  height: 300px;
  top: -100px;
  left: -100px;
  animation-duration: 20s;
  background: radial-gradient(circle, rgba(74, 144, 226, 0.2) 0%, transparent 70%);
}

.shape-2 {
  width: 200px;
  height: 200px;
  bottom: -80px;
  right: -80px;
  animation-duration: 25s;
  animation-direction: reverse;
  background: radial-gradient(circle, rgba(255, 107, 107, 0.2) 0%, transparent 70%);
}

.shape-3 {
  width: 150px;
  height: 150px;
  top: 30%;
  right: 20%;
  animation-duration: 15s;
  background: radial-gradient(circle, rgba(80, 227, 194, 0.2) 0%, transparent 70%);
}

.shape-4 {
  width: 100px;
  height: 100px;
  bottom: 20%;
  left: 20%;
  animation-duration: 18s;
  animation-direction: reverse;
  background: radial-gradient(circle, rgba(255, 209, 102, 0.2) 0%, transparent 70%);
}

.shape-5 {
  width: 250px;
  height: 250px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 22s;
  background: radial-gradient(circle, rgba(155, 89, 182, 0.2) 0%, transparent 70%);
}

.shape-6 {
  width: 180px;
  height: 180px;
  top: 70%;
  left: 10%;
  animation-duration: 28s;
  background: radial-gradient(circle, rgba(231, 76, 60, 0.2) 0%, transparent 70%);
}

@keyframes float {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  25% {
    transform: translate(20px, 20px) rotate(90deg);
  }
  50% {
    transform: translate(0, 40px) rotate(180deg);
  }
  75% {
    transform: translate(-20px, 20px) rotate(270deg);
  }
  100% {
    transform: translate(0, 0) rotate(360deg);
  }
}

.contract-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  z-index: 1;
  position: relative;
}

.top-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 30px;
  background: rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.app-title {
  color: white;
  font-size: 24px;
  font-weight: 700;
  margin: 0;
}

.navbar-center {
  flex: 1;
  margin: 0 20px;
}

:deep(.el-menu--horizontal) {
  border: none;
  background: transparent !important;
}

:deep(.el-menu--horizontal .el-menu-item) {
  color: white;
  border: none;
}

:deep(.el-menu--horizontal .el-menu-item:hover) {
  background: rgba(255, 255, 255, 0.2) !important;
}

:deep(.el-menu--horizontal .el-menu-item.is-active) {
  color: #4A90E2 !important;
  border: none;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: white;
}

.username {
  font-size: 16px;
  font-weight: 500;
}

.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 250px;
  background: rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  padding: 20px 0;
  height: 100%;
  box-shadow: 3px 0 10px rgba(0, 0, 0, 0.2);
}

.el-menu-vertical {
  border: none !important;
  height: 100%;
}

.el-menu-item,
.el-sub-menu__title {
  margin: 5px 10px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.el-menu-item:hover,
.el-sub-menu__title:hover {
  background-color: rgba(255, 255, 255, 0.1) !important;
}

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  overflow-y: auto;
  padding: 20px;
}

.contract-header {
  margin-bottom: 30px;
}

.contract-header h2 {
  color: #2c3e50;
  font-size: 28px;
  margin: 0 0 10px;
}

.contract-header p {
  color: #7f8c8d;
  margin: 0;
}

.contract-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.contract-card {
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.contract-list :deep(.el-table) {
  margin-top: 20px;
}

.reject-reason {
  color: #f56c6c;
}

.contract-detail {
  padding: 20px 0;
}

.contract-info {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 30px;
}

.info-item {
  display: flex;
  margin-bottom: 15px;
}

.info-item .label {
  width: 100px;
  font-weight: 600;
  color: #2c3e50;
}

.info-item .value {
  flex: 1;
  color: #7f8c8d;
}

.contract-terms h3 {
  margin: 0 0 20px;
  font-size: 22px;
  color: #2c3e50;
}

.term-section {
  margin-bottom: 25px;
}

.term-section h4 {
  margin: 0 0 10px;
  font-size: 18px;
  color: #2c3e50;
}

.term-section p {
  margin: 0;
  line-height: 1.6;
  color: #7f8c8d;
  white-space: pre-line;
}

.contract-preview {
  max-height: 500px;
  overflow-y: auto;
  padding: 20px;
  border: 1px solid #eee;
  border-radius: 8px;
  background: #fafafa;
}

.contract-preview h3 {
  text-align: center;
  margin-bottom: 20px;
  color: #2c3e50;
}

.contract-section {
  margin-bottom: 20px;
}

.contract-section h4 {
  margin: 0 0 15px;
  color: #2c3e50;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}

.contract-subsection {
  margin-bottom: 15px;
}

.contract-subsection h5 {
  margin: 0 0 8px;
  color: #2c3e50;
}

.contract-subsection p {
  margin: 0 0 5px;
  color: #7f8c8d;
  line-height: 1.5;
}

.agreement-section {
  margin: 20px 0;
  padding: 15px;
  background: #f0f9ff;
  border-radius: 8px;
  border: 1px solid #b3d9ff;
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

@media (max-width: 992px) {
  .sidebar {
    width: 80px;
  }

  .app-title,
  .el-menu-item span,
  .el-sub-menu__title span {
    display: none;
  }

  .contract-header {
    text-align: center;
  }

  .card-header {
    flex-direction: column;
    gap: 15px;
    align-items: flex-start;
  }

  .info-item {
    flex-direction: column;
    gap: 5px;
  }

  .info-item .label {
    width: auto;
  }
}
</style>
